home *** CD-ROM | disk | FTP | other *** search
- Function GetEnvVar(Const Env:String) : String;
- { return contents of environment variable "Env" - or an empty
- string if vairable does not exist
-
- e.g.,
- Var Command : String;
- begin
- Command := GetEnvVar('COMSPEC')+#0;
- WinExec(@Command[1], sw_Normal);
- end;
-
- }
-
- var
- p2 : pchar;
- i : Word;
- s : String;
-
- Begin
- Result := '';
- p2 := GetDOSEnvironment;
- while p2[0] <> #0 do
- begin
- s := StrPas(p2);
- if (Pos(UpperCase(Env), UpperCase(s)) = 1) then
- begin
- i := Pos('=', s);
- If i=0 then i := pos(#32, s);
- Delete(s,1,i);
- Result := s;
- Exit;
- end;
- while (p2[0] <> #0) do Inc(p2); { goto end of current }
- Inc(p2); { point to next }
- end;
- End {GetEnvVar};
-